package com.karst.essentials.chapter06
{
	import flash.events.Event;
	
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;

	internal class InteractionTemplate extends BasicView
	{
		public function InteractionTemplate( interactive : Boolean = false  )
		{
			super( 640, 480, true, interactive ) ;
			createView() ;
			startRendering() ;
		}

		protected var grid : DisplayObject3D = null ;
		protected function createView() : void
		{
			if( grid == null )
				grid = new DisplayObject3D() ;
			
			var cols : uint = 14 ;
			var rows : uint = 10 ;
			var size : uint = 80 ;
			var spacing : uint = 88 ;
			var offsetX : Number = cols * spacing * .5 - spacing * .5 ;
			var offsetY : Number = rows * spacing * .5 - spacing * .5 ;
			for( var i : uint = 0 ; i < cols ; i ++ )
			{
				for( var j : uint = 0 ; j < rows ; j++ )
				{
					var plane : Plane = new Plane( new ColorMaterial( 0xFFFFFF * Math.random()), size, size ) ;
					plane.x = i * spacing - offsetX ;
					plane.y = j * spacing - offsetY ;
					grid.addChild( plane ) ;
				}
			}
			
			scene.addChild( grid ) ;
		}
	}
}